// 1. 导入 Metadata type
import { Metadata } from "next";
// 2. 定义 params 的类型，并应用
type Props = {
    params: Promise<{ productId: string }>
}
// 3. 使用 generateMetadata 获取数据
export const generateMetadata = async ({ params }: Props): Promise<Metadata> => {
    const id = (await params).productId;
    const title = await new Promise((resolve) => {
        setTimeout(() => {
            resolve(`iPhone ${id}`);
        }, 100);
    });
    return {
        title: `Product ${title}`,
    }
}

export default async function ProductDetail({ params }: Props) {
    const productId = (await params).productId;
    return (
        <h1>Product {productId} detail</h1>
    )
}
